//
//  LogisticsCell.m
//  NewPro
//
//  Created by RYX on 2018/10/23.
//  Copyright © 2018年 何荧红. All rights reserved.
//

#import "LogisticsCell.h"
#import "LogisticsModel.h"

@interface LogisticsCell ()

@end

@implementation LogisticsCell

+ (instancetype)tempWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    
    NSString *identity = @"CELL1";
    NSInteger index = 0;
    
    switch (indexPath.row) {
        case 0:
            
            identity = @"CELL1";
            index = 0;
            break;
            
        default:
            
            identity = @"CELL2";
            index = 1;
            break;
    }
    
    LogisticsCell *cell = [tableView dequeueReusableCellWithIdentifier:identity];
    
    if (cell == nil) {
        
        cell = [self cellWithRow:index];
    }
    
    return cell;
}

+ (instancetype)cellWithRow:(NSInteger)row{
    
    ClassName
    return [[[NSBundle mainBundle] loadNibNamed:className owner:self options:nil] objectAtIndex:row];
}



- (void)setModel:(LogisticsModel *)model withRow:(NSInteger)row{
    
    switch (row) {
        case 0:
            
            _cell1_la1.attributedText = [self getAttributedStringWithMsg:model.remark];
            _cell1_la2.text = model.datetime;
            break;
            
        default:
            
            _cell2_la1.attributedText = [self getAttributedStringWithMsg:model.remark];
            _cell2_la2.text = model.datetime;
            break;
    }

}

- (NSMutableAttributedString *)getAttributedStringWithMsg:(NSString *)msg{
    
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
    [paragraphStyle setLineSpacing:1];
    NSMutableAttributedString *attributedString =  [[NSMutableAttributedString alloc] initWithString:msg attributes:@{NSKernAttributeName : @(1.0f)}];
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, msg.length)];
    return attributedString;
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
